package com.medical.admin.patient.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.medical.admin.patient.entity.Patient;

public interface PatientMapper extends BaseMapper<Patient> {
    default int updateByPatientId(Patient patient) {
        QueryWrapper<Patient> qw = new QueryWrapper<>();
        qw.lambda().eq(Patient::getPatientId, patient.getPatientId());
        return this.update(patient, qw);
    }

    default IPage<Patient> selectPatientList(Page<Patient> objectPage) {
        QueryWrapper<Patient> qw = new QueryWrapper<>();
        qw.lambda().eq(Patient::getState, 1);
        return this.selectPage(objectPage, qw);
    }

    default Patient select(Patient patient) {
        QueryWrapper<Patient> qw = new QueryWrapper<>();
        qw.lambda().eq(Patient::getCardNumber, patient.getCardNumber()).eq(Patient::getPatientPhone, patient.getPatientPhone());
        return this.selectOne(qw);
    }
}